<?php

declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class ConfigDataAddThree extends AbstractMigration
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change(): void
    {
        $table = $this->table('ctmon_config');
        $builder = $this->getInsertBuilder();
        $root = $builder->insert(["parent_id", "name", "code", "type", "tip", "size", "isshow", "value", "create_time"])
            ->into($table->getName())
            ->values([
                "parent_id" => 0,
                "name" => "OSS配置",
                "code" => "oss",
                "type" => "text",
                "tip" => "OSS配置",
                "size" => "40",
                "isshow" => 1,
                "value" => "",
                "create_time" => time(),
            ])
            ->execute();
        $parent_id = $root->lastInsertId('ctmon_config', 'id');
        $subBuilder = $this->getInsertBuilder();
        $subBuilder->insert(["parent_id", "name", "code", "type", "tip", "size", "isshow", "value", "create_time"])
            ->into($table->getName())
            ->values(["parent_id" => $parent_id, "name" => "ACCESS_KEY_ID", "code" => "ACCESS_KEY_ID", "type" => "text", "tip" => "ACCESS_KEY_ID", "size" => "100", "isshow" => 1, "value" => "LTAI5tG3EnE3FroszPFfhGWr", "create_time" => time(),])
            ->values(["parent_id" => $parent_id, "name" => "ACCESS_KEY_SECRET", "code" => "ACCESS_KEY_SECRET", "type" => "text", "tip" => "ACCESS_KEY_SECRET", "size" => "100", "isshow" => 1, "value" => "GsY2w3stJt3fEf54AjXYrDIysPS2qv", "create_time" => time(),])
            ->values(["parent_id" => $parent_id, "name" => "ENDPOINT", "code" => "ENDPOINT", "type" => "text", "tip" => "ENDPOINT", "size" => "100", "isshow" => 1, "value" => "oss-cn-shenzhen.aliyuncs.com", "create_time" => time(),])
            ->values(["parent_id" => $parent_id, "name" => "BUCKET", "code" => "BUCKET", "type" => "text", "tip" => "BUCKET", "size" => "100", "isshow" => 1, "value" => "html-mtingche", "create_time" => time(),])
            ->values(["parent_id" => $parent_id, "name" => "BIND_DOMAIN", "code" => "BIND_DOMAIN", "type" => "text", "tip" => "BIND_DOMAIN", "size" => "100", "isshow" => 1, "value" => "https://html-mtingche.ctmon.com", "create_time" => time(),])
            ->values(["parent_id" => $parent_id, "name" => "PRODUCT_DOMAIN", "code" => "PRODUCT_DOMAIN", "type" => "text", "tip" => "PRODUCT_DOMAIN", "size" => "100", "isshow" => 1, "value" => "http://html.mtingche.com", "create_time" => time(),])
            ->values(["parent_id" => $parent_id, "name" => "IS_ENABLED", "code" => "IS_ENABLED", "type" => "radio", "tip" => "是否打开OSS", "size" => "100", "isshow" => 1, "value" => "1", "create_time" => time(),])
            ->execute();
    }
}
